<template>
  <div class="FirstMenu">
    <el-container>
      <el-aside width="200px">
        <div class="logo">
          <img src="image/logo.jpg" alt="">
        </div>
        <el-row class="tac">
          <el-col :span="24">
            <el-menu default-active="1-1"
                     class="el-menu-vertical-demo"
                     @open="handleOpen"
                     @close="handleClose"
                     :unique-opened="true"
                     background-color="#19578B"
                     text-color="#fff"
                     active-text-color="#ffd04b">
              <el-submenu index="1">
                <template slot="title">
                  <i class="el-icon-menu"></i>
                  <span>医院信息管理</span>
                </template>

                <el-menu-item index="1-1">
                  <router-link to="/hospital">医院管理</router-link>
                </el-menu-item>

                <el-menu-item index="1-2">
                  <router-link to="/doctor">医生管理</router-link>
                </el-menu-item>
              </el-submenu>
              <el-submenu index="2">
                <template slot="title">
                  <i class="el-icon-menu"></i>
                  <span>患者管理</span>
                </template>
                <el-menu-item index="2-1">
                  <router-link to="/patient">患者管理</router-link>
                </el-menu-item>
              </el-submenu>
              <el-submenu index="3">
                <template slot="title">
                  <i class="el-icon-menu"></i>
                  <span>诊疗活动管理</span>
                </template>
                <el-menu-item index="3-1">
                  <router-link to="/clinicActivity">诊疗活动</router-link>
                </el-menu-item>
              </el-submenu>
              <el-submenu index="4">
                <template slot="title">
                  <i class="el-icon-menu"></i>
                  <span>病例探讨管理</span>
                </template>
                <el-menu-item index="4-1">
                  <router-link to="/discussion">病例探讨</router-link>
                </el-menu-item>
              </el-submenu>
              <el-submenu index="5">
                <template slot="title">
                  <i class="el-icon-menu"></i>
                  <span>交易信息统计</span>
                </template>
                <el-menu-item index="5-1">
                  <router-link to="/trade">交易信息统计</router-link>
                </el-menu-item>
              </el-submenu>
              <el-submenu index="6">
                <template slot="title">
                  <i class="el-icon-menu"></i>
                  <span>角色管理</span>
                </template>
                <el-menu-item index="6-1">
                  <router-link to="/role">角色管理</router-link>
                </el-menu-item>
              </el-submenu>
              <el-submenu index="7">
                <template slot="title">
                  <i class="el-icon-menu"></i>
                  <span>首页banner</span>
                </template>
                <el-menu-item index="7-1">
                  <router-link to="/banner">首页banner</router-link>
                </el-menu-item>
              </el-submenu>
            </el-menu>
          </el-col>
        </el-row>
      </el-aside>
      <el-container>
        <el-header>
          <div class="headerMain">
            <h1>癫痫医院管理系统</h1>
            <div class="msg">
              <span>用户名：{{ loginUserInfo.msg }}</span>
              <span>角色：</span><span></span>
              <el-button size="mini" type="text" @click="userLoginOut">退出登录</el-button>
            </div>
          </div>
        </el-header>
        <el-container>
          <el-main>
            <router-view></router-view>
          </el-main>
          <el-footer>癫痫医护APP-版权所有 © 2022</el-footer>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import {mapGetters, mapActions} from 'vuex'

export default {
  name: "FirstMenu",
  computed: {
    ...mapGetters(['loginUserInfo'])
  },
  data() {
    return {}
  },
  mounted() {
    /*    this.setNoRefresh();
        // 关闭浏览器窗口的时候清空浏览器缓存在localStorage的数据
        window.onbeforeunload = function (e) {
          window.localStorage.clear();
        }*/
  },
  methods: {
    ...mapActions(['loginOut', 'setNoRefresh']),
    //退出登录
    userLoginOut() {
      this.$service.loginService.outLogin().then(res => {
        if (res.data.code == 1) {
          this.$message({
            message: '已退出',
            type: 'success'
          });
          this.loginOut();
          this.$router.push('/');
        }else {
          this.$message.error('退出失败！');
        }
      })
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  }
}
</script>

<style scoped lang="less">

.el-aside {
  background-color: #19578B;

  .el-submenu {
    width: 200px;
  }

  .logo {
    width: 100px;
    height: 100px;
    margin: 10px auto;

    img {
      width: 100%;
      border-radius: 50px;
    }
  }

  .el-col {
    width: 100%;
  }
}

.el-header {
  background-color: #19578B;
  display: flex;
  flex-direction: column;
  justify-content: center;


  .headerMain {
    display: flex;
    justify-content: right;
    align-items: center;

    h1 {
      font-size: 25px;
    }

    .msg {
      width: 40%;
      margin-left: 5%;
      display: flex;
      justify-content: space-around;
      align-items: center;
    }
  }
}

.el-footer {
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
